package com.example.demo.service;

import com.example.demo.common.domain.User;
import com.example.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminService {
    @Autowired
    private UserMapper userMapper;
    public  String login(User user){
        Boolean flag;
        String message="";
        String Uname=user.getuName();
        System.out.println(Uname);

        User user1  =userMapper.selectByPrimaryKey(Uname);

        if (user1==null){
            message="账户不存在";
            flag=false;
        } else {
            message="正确";
            flag=true;
        }
        if (flag){
            if (user.getuPwd().equals(user1.getuPwd())){
                message="正确";
                flag=true;
            }else{
                message="密码不正确，重新输入";
                flag=false;
            }
        }
        if(flag) {
            if (user1.getRole() > 0) {
                message = "正确";
            } else {
                message = "您不是管理员";
            }
        }
        return message;
    }
}
